<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.util.Enumeration"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>HeaderInformation</title>
</head>
<body>
<div>http통신에서 요청과 응답은 text로 만들어져 있음</div>
<div>두 부분 header와  body(content=html포함)로 구성되어 있음</div>
<div>헤더에 포함된 정보를 출력</div>
<%
String country = request.getHeader("accept-language");
if(country.startsWith("ko-KR")){%>
	<div>한국에서 접속</div><%}
else{%>
	<div>해외에서 접속</div>
<%}%>

<%
String agent = request.getHeader("user-agent");
if(agent.contains("MSIE")){
	int index = agent.indexOf("MSIE");
	String version = agent.substring(index,index+8);%>
	<div>인터넷 익스플로러 사용중</div><%}
else{%>
	<div>인터넷 익스플로러 사용X</div>
<%}%>
<table border="1">
	<tr>
		<td>헤더이름</td>
		<td>헤더값</td>
	</tr>
<%
Enumeration e = request.getHeaderNames();
while(e.hasMoreElements())
{
	String headerName=(String)e.nextElement();
%>
	<tr>
		<td><%=headerName %></td>
		<td><%=request.getHeader(headerName) %></td>
	</tr>
<%}%>
</table>

</body>
</html>